//
// Created by HhL on 2021/7/8.
//

#include <stdio.h>
#include <string.h>
#include<stdlib.h>

#ifndef C_STUDY_HEAP_UTILS_H
#define C_STUDY_HEAP_UTILS_H

int* getSpace() {
    int* p = malloc(sizeof(int) * 5);
    if (p == NULL) {
        return 0;
    }
    for (int i = 0; i < 5; i++) {
        p[i] = i + 100;
    }
    return p;
}

extern int g_a = 1000; //在C语言下  全局变量前都隐式加了关键字 extern

void allocateSpace(char* pp) {
    char* temp = malloc(100);
    memset(temp, 0, 100);
    strcpy(temp, "hello world");
    pp = temp;
}

//需要指针指向才有值
void allocateSpace2(char** pp) {
    char* temp = malloc(100);
    memset(temp, 0, 100);
    strcpy(temp, "hello world");

    *pp = temp;

}

#endif //C_STUDY_HEAP_UTILS_H
